home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
progutil
/
stdwin.zoo
/
alfa
/
measure.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-10-18
|
721b
|
56 lines
/* STANDARD WINDOWS -- TEXT MEASURING. */
#include "alfa.h"
int
wlineheight()
{
return 1;
}
#define CHARWIDTH(c) ((c) < ' ' ? 2 : (c) < 0177 ? 1 : (c) < 0200 ? 2 : 4)
int
wtextwidth(str, len)
char *str;
int len;
{
int i;
int w= 0;
if (len < 0)
len= (int)strlen(str);
for (i= 0; i < len; ++i) {
unsigned char c= str[i];
w += CHARWIDTH(c);
}
return w;
}
int
wcharwidth(c)
int c;
{
c &= 0xff;
return CHARWIDTH(c);
}
int
wtextbreak(str, len, width)
char *str;
int len;
int width;
{
int i;
if (len < 0)
len= (int)strlen(str);
for (i= 0; i < len && width > 0; ++i) {
unsigned char c= str[i];
width -= CHARWIDTH(c);
if (width < 0)
break; /* Before incrementing i! */
}
return i;
}